{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "noVOkd8IHVTP"
      },
      "source": [
        "Licensed under the Apache License, Version 2.0"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "GlhZG8coOYrw"
      },
      "source": [
        "# Copy file to COLAB local storage"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "executionInfo": {
          "elapsed": 3526,
          "status": "ok",
          "timestamp": 1703008534363,
          "user": {
            "displayName": "Scott Geraedts",
            "userId": "00641703995476599052"
          },
          "user_tz": 300
        },
        "id": "VoWQfRoAKRo9",
        "outputId": "b901899a-8677-4aef-a19c-71ebcdf1617e"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Updated property [core/project].\n",
            "gs://contrails_measurement_paper_data/\n",
            "gs://contrails_predictions_muac/\n"
          ]
        }
      ],
      "source": [
        "from google.colab import auth\n",
        "auth.authenticate_user()\n",
        "project_id = 'contrails-predictions-external'\n",
        "!gcloud config set project {project_id}\n",
        "!gsutil ls"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "executionInfo": {
          "elapsed": 4755,
          "status": "ok",
          "timestamp": 1703008586570,
          "user": {
            "displayName": "Scott Geraedts",
            "userId": "00641703995476599052"
          },
          "user_tz": 300
        },
        "id": "a7AUjWsZM4rl",
        "outputId": "0f66dc79-48be-4f3d-aab9-566941d5cb6c"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Copying gs://contrails_measurement_paper_data/dataset.parquet.gzip...\n",
            "/ [0 files][    0.0 B/248.5 MiB]                                                \r==\u003e NOTE: You are downloading one or more large file(s), which would\n",
            "run significantly faster if you enabled sliced object downloads. This\n",
            "feature is enabled by default but requires that compiled crcmod be\n",
            "installed (see \"gsutil help crcmod\").\n",
            "\n",
            "/ [1 files][248.5 MiB/248.5 MiB]                                                \n",
            "Operation completed over 1 objects/248.5 MiB.                                    \n"
          ]
        }
      ],
      "source": [
        "!gsutil cp gs://contrails_measurement_paper_data/dataset.parquet.gzip /content"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "MZFQMplDOLZ7"
      },
      "outputs": [],
      "source": [
        "!gunzip --suffix=.gzip /content/dataset.parquet.gzip"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "IVUs9ECHOdPk"
      },
      "source": [
        "# Open data"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "bXcJ-x7LOTUe"
      },
      "outputs": [],
      "source": [
        "import pandas as pd\n",
        "import numpy as np\n",
        "df = pd.read_parquet('/content/dataset.parquet')"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 424
        },
        "executionInfo": {
          "elapsed": 207,
          "status": "ok",
          "timestamp": 1703008633473,
          "user": {
            "displayName": "Scott Geraedts",
            "userId": "00641703995476599052"
          },
          "user_tz": 300
        },
        "id": "qmk0oAfHOV-l",
        "outputId": "6734f1c1-bb45-4471-f567-d74d86484fd7"
      },
      "outputs": [
        {
          "data": {
            "application/vnd.google.colaboratory.intrinsic+json": {
              "type": "dataframe",
              "variable_name": "df"
            },
            "text/html": [
              "\n",
              "  \u003cdiv id=\"df-77c87664-6c82-4b54-b1ea-0034cab25e78\" class=\"colab-df-container\"\u003e\n",
              "    \u003cdiv\u003e\n",
              "\u003cstyle scoped\u003e\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "\u003c/style\u003e\n",
              "\u003ctable border=\"1\" class=\"dataframe\"\u003e\n",
              "  \u003cthead\u003e\n",
              "    \u003ctr style=\"text-align: right;\"\u003e\n",
              "      \u003cth\u003e\u003c/th\u003e\n",
              "      \u003cth\u003elatitude\u003c/th\u003e\n",
              "      \u003cth\u003elongitude\u003c/th\u003e\n",
              "      \u003cth\u003ealtitude_m\u003c/th\u003e\n",
              "      \u003cth\u003etimestamp\u003c/th\u003e\n",
              "      \u003cth\u003eaircraft_type\u003c/th\u003e\n",
              "      \u003cth\u003ematch\u003c/th\u003e\n",
              "    \u003c/tr\u003e\n",
              "  \u003c/thead\u003e\n",
              "  \u003ctbody\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003e0\u003c/th\u003e\n",
              "      \u003ctd\u003e42.459179\u003c/td\u003e\n",
              "      \u003ctd\u003e-85.621165\u003c/td\u003e\n",
              "      \u003ctd\u003e10086.536109\u003c/td\u003e\n",
              "      \u003ctd\u003e1.568199e+09\u003c/td\u003e\n",
              "      \u003ctd\u003eB738\u003c/td\u003e\n",
              "      \u003ctd\u003eFalse\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003e1\u003c/th\u003e\n",
              "      \u003ctd\u003e42.461779\u003c/td\u003e\n",
              "      \u003ctd\u003e-85.790222\u003c/td\u003e\n",
              "      \u003ctd\u003e10481.250213\u003c/td\u003e\n",
              "      \u003ctd\u003e1.568199e+09\u003c/td\u003e\n",
              "      \u003ctd\u003eB738\u003c/td\u003e\n",
              "      \u003ctd\u003eFalse\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003e2\u003c/th\u003e\n",
              "      \u003ctd\u003e42.464045\u003c/td\u003e\n",
              "      \u003ctd\u003e-85.948090\u003c/td\u003e\n",
              "      \u003ctd\u003e10820.163119\u003c/td\u003e\n",
              "      \u003ctd\u003e1.568199e+09\u003c/td\u003e\n",
              "      \u003ctd\u003eB738\u003c/td\u003e\n",
              "      \u003ctd\u003eFalse\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003e3\u003c/th\u003e\n",
              "      \u003ctd\u003e42.464710\u003c/td\u003e\n",
              "      \u003ctd\u003e-86.117779\u003c/td\u003e\n",
              "      \u003ctd\u003e10964.867410\u003c/td\u003e\n",
              "      \u003ctd\u003e1.568200e+09\u003c/td\u003e\n",
              "      \u003ctd\u003eB738\u003c/td\u003e\n",
              "      \u003ctd\u003eFalse\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003e4\u003c/th\u003e\n",
              "      \u003ctd\u003e42.450269\u003c/td\u003e\n",
              "      \u003ctd\u003e-86.253707\u003c/td\u003e\n",
              "      \u003ctd\u003e10964.867410\u003c/td\u003e\n",
              "      \u003ctd\u003e1.568200e+09\u003c/td\u003e\n",
              "      \u003ctd\u003eB738\u003c/td\u003e\n",
              "      \u003ctd\u003eFalse\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003e...\u003c/th\u003e\n",
              "      \u003ctd\u003e...\u003c/td\u003e\n",
              "      \u003ctd\u003e...\u003c/td\u003e\n",
              "      \u003ctd\u003e...\u003c/td\u003e\n",
              "      \u003ctd\u003e...\u003c/td\u003e\n",
              "      \u003ctd\u003e...\u003c/td\u003e\n",
              "      \u003ctd\u003e...\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003e5\u003c/th\u003e\n",
              "      \u003ctd\u003e37.972475\u003c/td\u003e\n",
              "      \u003ctd\u003e-109.322365\u003c/td\u003e\n",
              "      \u003ctd\u003e10660.226731\u003c/td\u003e\n",
              "      \u003ctd\u003e1.574108e+09\u003c/td\u003e\n",
              "      \u003ctd\u003eB739\u003c/td\u003e\n",
              "      \u003ctd\u003eFalse\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003e6\u003c/th\u003e\n",
              "      \u003ctd\u003e38.017960\u003c/td\u003e\n",
              "      \u003ctd\u003e-109.203796\u003c/td\u003e\n",
              "      \u003ctd\u003e10660.226731\u003c/td\u003e\n",
              "      \u003ctd\u003e1.574108e+09\u003c/td\u003e\n",
              "      \u003ctd\u003eB739\u003c/td\u003e\n",
              "      \u003ctd\u003eFalse\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003e7\u003c/th\u003e\n",
              "      \u003ctd\u003e38.062994\u003c/td\u003e\n",
              "      \u003ctd\u003e-109.085819\u003c/td\u003e\n",
              "      \u003ctd\u003e10660.226731\u003c/td\u003e\n",
              "      \u003ctd\u003e1.574108e+09\u003c/td\u003e\n",
              "      \u003ctd\u003eB739\u003c/td\u003e\n",
              "      \u003ctd\u003eFalse\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003e8\u003c/th\u003e\n",
              "      \u003ctd\u003e38.124279\u003c/td\u003e\n",
              "      \u003ctd\u003e-108.924713\u003c/td\u003e\n",
              "      \u003ctd\u003e10660.226731\u003c/td\u003e\n",
              "      \u003ctd\u003e1.574108e+09\u003c/td\u003e\n",
              "      \u003ctd\u003eB739\u003c/td\u003e\n",
              "      \u003ctd\u003eFalse\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003e9\u003c/th\u003e\n",
              "      \u003ctd\u003e38.178574\u003c/td\u003e\n",
              "      \u003ctd\u003e-108.781200\u003c/td\u003e\n",
              "      \u003ctd\u003e10660.226731\u003c/td\u003e\n",
              "      \u003ctd\u003e1.574108e+09\u003c/td\u003e\n",
              "      \u003ctd\u003eB739\u003c/td\u003e\n",
              "      \u003ctd\u003eFalse\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "  \u003c/tbody\u003e\n",
              "\u003c/table\u003e\n",
              "\u003cp\u003e17109623 rows × 6 columns\u003c/p\u003e\n",
              "\u003c/div\u003e\n",
              "    \u003cdiv class=\"colab-df-buttons\"\u003e\n",
              "\n",
              "  \u003cdiv class=\"colab-df-container\"\u003e\n",
              "    \u003cbutton class=\"colab-df-convert\" onclick=\"convertToInteractive('df-77c87664-6c82-4b54-b1ea-0034cab25e78')\"\n",
              "            title=\"Convert this dataframe to an interactive table.\"\n",
              "            style=\"display:none;\"\u003e\n",
              "\n",
              "  \u003csvg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\"\u003e\n",
              "    \u003cpath d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/\u003e\n",
              "  \u003c/svg\u003e\n",
              "    \u003c/button\u003e\n",
              "\n",
              "  \u003cstyle\u003e\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    .colab-df-buttons div {\n",
              "      margin-bottom: 4px;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  \u003c/style\u003e\n",
              "\n",
              "    \u003cscript\u003e\n",
              "      const buttonEl =\n",
              "        document.querySelector('#df-77c87664-6c82-4b54-b1ea-0034cab25e78 button.colab-df-convert');\n",
              "      buttonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "      async function convertToInteractive(key) {\n",
              "        const element = document.querySelector('#df-77c87664-6c82-4b54-b1ea-0034cab25e78');\n",
              "        const dataTable =\n",
              "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                    [key], {});\n",
              "        if (!dataTable) return;\n",
              "\n",
              "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "          '\u003ca target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb\u003edata table notebook\u003c/a\u003e'\n",
              "          + ' to learn more about interactive tables.';\n",
              "        element.innerHTML = '';\n",
              "        dataTable['output_type'] = 'display_data';\n",
              "        await google.colab.output.renderOutput(dataTable, element);\n",
              "        const docLink = document.createElement('div');\n",
              "        docLink.innerHTML = docLinkHtml;\n",
              "        element.appendChild(docLink);\n",
              "      }\n",
              "    \u003c/script\u003e\n",
              "  \u003c/div\u003e\n",
              "\n",
              "\n",
              "\u003cdiv id=\"df-94fb9eb1-d2ef-41d7-a2ce-2d662810b4b4\"\u003e\n",
              "  \u003cbutton class=\"colab-df-quickchart\" onclick=\"quickchart('df-94fb9eb1-d2ef-41d7-a2ce-2d662810b4b4')\"\n",
              "            title=\"Suggest charts\"\n",
              "            style=\"display:none;\"\u003e\n",
              "\n",
              "\u003csvg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
              "     width=\"24px\"\u003e\n",
              "    \u003cg\u003e\n",
              "        \u003cpath d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/\u003e\n",
              "    \u003c/g\u003e\n",
              "\u003c/svg\u003e\n",
              "  \u003c/button\u003e\n",
              "\n",
              "\u003cstyle\u003e\n",
              "  .colab-df-quickchart {\n",
              "      --bg-color: #E8F0FE;\n",
              "      --fill-color: #1967D2;\n",
              "      --hover-bg-color: #E2EBFA;\n",
              "      --hover-fill-color: #174EA6;\n",
              "      --disabled-fill-color: #AAA;\n",
              "      --disabled-bg-color: #DDD;\n",
              "  }\n",
              "\n",
              "  [theme=dark] .colab-df-quickchart {\n",
              "      --bg-color: #3B4455;\n",
              "      --fill-color: #D2E3FC;\n",
              "      --hover-bg-color: #434B5C;\n",
              "      --hover-fill-color: #FFFFFF;\n",
              "      --disabled-bg-color: #3B4455;\n",
              "      --disabled-fill-color: #666;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart {\n",
              "    background-color: var(--bg-color);\n",
              "    border: none;\n",
              "    border-radius: 50%;\n",
              "    cursor: pointer;\n",
              "    display: none;\n",
              "    fill: var(--fill-color);\n",
              "    height: 32px;\n",
              "    padding: 0;\n",
              "    width: 32px;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart:hover {\n",
              "    background-color: var(--hover-bg-color);\n",
              "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "    fill: var(--button-hover-fill-color);\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart-complete:disabled,\n",
              "  .colab-df-quickchart-complete:disabled:hover {\n",
              "    background-color: var(--disabled-bg-color);\n",
              "    fill: var(--disabled-fill-color);\n",
              "    box-shadow: none;\n",
              "  }\n",
              "\n",
              "  .colab-df-spinner {\n",
              "    border: 2px solid var(--fill-color);\n",
              "    border-color: transparent;\n",
              "    border-bottom-color: var(--fill-color);\n",
              "    animation:\n",
              "      spin 1s steps(1) infinite;\n",
              "  }\n",
              "\n",
              "  @keyframes spin {\n",
              "    0% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "      border-left-color: var(--fill-color);\n",
              "    }\n",
              "    20% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    30% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    40% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    60% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    80% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "    90% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "  }\n",
              "\u003c/style\u003e\n",
              "\n",
              "  \u003cscript\u003e\n",
              "    async function quickchart(key) {\n",
              "      const quickchartButtonEl =\n",
              "        document.querySelector('#' + key + ' button');\n",
              "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
              "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
              "      try {\n",
              "        const charts = await google.colab.kernel.invokeFunction(\n",
              "            'suggestCharts', [key], {});\n",
              "      } catch (error) {\n",
              "        console.error('Error during call to suggestCharts:', error);\n",
              "      }\n",
              "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
              "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
              "    }\n",
              "    (() =\u003e {\n",
              "      let quickchartButtonEl =\n",
              "        document.querySelector('#df-94fb9eb1-d2ef-41d7-a2ce-2d662810b4b4 button');\n",
              "      quickchartButtonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "    })();\n",
              "  \u003c/script\u003e\n",
              "\u003c/div\u003e\n",
              "\n",
              "  \u003cdiv id=\"id_eea9c4f1-7530-4aa9-baba-dea0f45d3400\"\u003e\n",
              "    \u003cstyle\u003e\n",
              "      .colab-df-generate {\n",
              "        background-color: #E8F0FE;\n",
              "        border: none;\n",
              "        border-radius: 50%;\n",
              "        cursor: pointer;\n",
              "        display: none;\n",
              "        fill: #1967D2;\n",
              "        height: 32px;\n",
              "        padding: 0 0 0 0;\n",
              "        width: 32px;\n",
              "      }\n",
              "\n",
              "      .colab-df-generate:hover {\n",
              "        background-color: #E2EBFA;\n",
              "        box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "        fill: #174EA6;\n",
              "      }\n",
              "\n",
              "      [theme=dark] .colab-df-generate {\n",
              "        background-color: #3B4455;\n",
              "        fill: #D2E3FC;\n",
              "      }\n",
              "\n",
              "      [theme=dark] .colab-df-generate:hover {\n",
              "        background-color: #434B5C;\n",
              "        box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "        filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "        fill: #FFFFFF;\n",
              "      }\n",
              "    \u003c/style\u003e\n",
              "    \u003cbutton class=\"colab-df-generate\" onclick=\"generateWithVariable('df')\"\n",
              "            title=\"Generate code using this dataframe.\"\n",
              "            style=\"display:none;\"\u003e\n",
              "\n",
              "  \u003csvg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
              "       width=\"24px\"\u003e\n",
              "    \u003cpath d=\"M7,19H8.4L18.45,9,17,7.55,7,17.6ZM5,21V16.75L18.45,3.32a2,2,0,0,1,2.83,0l1.4,1.43a1.91,1.91,0,0,1,.58,1.4,1.91,1.91,0,0,1-.58,1.4L9.25,21ZM18.45,9,17,7.55Zm-12,3A5.31,5.31,0,0,0,4.9,8.1,5.31,5.31,0,0,0,1,6.5,5.31,5.31,0,0,0,4.9,4.9,5.31,5.31,0,0,0,6.5,1,5.31,5.31,0,0,0,8.1,4.9,5.31,5.31,0,0,0,12,6.5,5.46,5.46,0,0,0,6.5,12Z\"/\u003e\n",
              "  \u003c/svg\u003e\n",
              "    \u003c/button\u003e\n",
              "    \u003cscript\u003e\n",
              "      (() =\u003e {\n",
              "      const buttonEl =\n",
              "        document.querySelector('#id_eea9c4f1-7530-4aa9-baba-dea0f45d3400 button.colab-df-generate');\n",
              "      buttonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "      buttonEl.onclick = () =\u003e {\n",
              "        google.colab.notebook.generateWithVariable('df');\n",
              "      }\n",
              "      })();\n",
              "    \u003c/script\u003e\n",
              "  \u003c/div\u003e\n",
              "\n",
              "    \u003c/div\u003e\n",
              "  \u003c/div\u003e\n"
            ],
            "text/plain": [
              "     latitude   longitude    altitude_m     timestamp aircraft_type  match\n",
              "0   42.459179  -85.621165  10086.536109  1.568199e+09          B738  False\n",
              "1   42.461779  -85.790222  10481.250213  1.568199e+09          B738  False\n",
              "2   42.464045  -85.948090  10820.163119  1.568199e+09          B738  False\n",
              "3   42.464710  -86.117779  10964.867410  1.568200e+09          B738  False\n",
              "4   42.450269  -86.253707  10964.867410  1.568200e+09          B738  False\n",
              "..        ...         ...           ...           ...           ...    ...\n",
              "5   37.972475 -109.322365  10660.226731  1.574108e+09          B739  False\n",
              "6   38.017960 -109.203796  10660.226731  1.574108e+09          B739  False\n",
              "7   38.062994 -109.085819  10660.226731  1.574108e+09          B739  False\n",
              "8   38.124279 -108.924713  10660.226731  1.574108e+09          B739  False\n",
              "9   38.178574 -108.781200  10660.226731  1.574108e+09          B739  False\n",
              "\n",
              "[17109623 rows x 6 columns]"
            ]
          },
          "execution_count": 6,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "df"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "8MG4XphkOWIK"
      },
      "outputs": [],
      "source": [
        "# Let's make a prediction of which flights will make contrails\n",
        "# We'll predict that all flights with altitudes between 11-12 km make a contrail\n",
        "# Obviously this isn't a very good prediction.\n",
        "# In reality you would want to look up the weather data for each latitude/longitude/altitude/timestamp\n",
        "# and make predictions based on that\n",
        "predictions = (df.altitude_m \u003e 11000) \u0026 (df.altitude_m \u003c 12000)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "executionInfo": {
          "elapsed": 241,
          "status": "ok",
          "timestamp": 1703012246555,
          "user": {
            "displayName": "Scott Geraedts",
            "userId": "00641703995476599052"
          },
          "user_tz": 300
        },
        "id": "uYaq2wjAPF2O",
        "outputId": "940161e3-f829-4ddd-b559-44b1f8b7524f"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Precision: 0.04\n",
            "Recall: 0.31\n"
          ]
        }
      ],
      "source": [
        "true_positives = predictions \u0026 df.match\n",
        "false_positives = predictions \u0026 ~df.match\n",
        "false_negatives = ~predictions \u0026 df.match\n",
        "\n",
        "precision = np.sum(true_positives) / (np.sum(true_positives) + np.sum(false_positives))\n",
        "recall = np.sum(true_positives) / (np.sum(true_positives) + np.sum(false_negatives))\n",
        "\n",
        "# Print the precision and recall. Obviously it's not very good but it might be better\n",
        "# with a weather-based model\n",
        "print(f\"Precision: {precision:.2f}\")\n",
        "print(f\"Recall: {recall:.2f}\")\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "6ENES1fVcG5c"
      },
      "outputs": [],
      "source": []
    }
  ],
  "metadata": {
    "colab": {
      "provenance": [
        {
          "file_id": "1mKOx-wsim0sseXRYuB2vVhMdGY9CwCo7",
          "timestamp": 1703018873049
        }
      ]
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
